import i18n from '@/i18n'
import { Body, Controller, Post } from '@nestjs/common'
import { ApiOperation, ApiTags } from '@nestjs/swagger'
import { MetaRealtimeDataWsService } from '../websocket/meta-realtime-data-ws/meta-realtime-data-ws.service'
import { MetaOpenApiPushWsDataDto } from './dto/meta-open-api-push-ws-data.dto'

@ApiTags(i18n.t('app-meta.meta-open-api.meta-open-api.12150118-0'))
@Controller({ path: 'open_api', version: '1' })
export class MetaOpenApiController {
  constructor(private readonly realtimeDataWsService: MetaRealtimeDataWsService) {}

  @ApiOperation({ summary: i18n.t('app-meta.meta-open-api.meta-open-api.12150118-1') })
  @Post('push_ws_data')
  pushWsData(@Body() param: MetaOpenApiPushWsDataDto): Promise<void> {
    return this.realtimeDataWsService.send({
      uniqueId: param.uniqueId,
      action: param.action,
      data: param.data,
    })
  }
}
